#pragma once
#ifndef _TIME_UTILS_H_
#define _TIME_UTILS_H_
#ifdef WIN32
#pragma execution_character_set("utf-8")
#endif // WIN32

#include <iostream>
#include <chrono>
#include <QString>
#include <QDateTime>
#include <QTime>
#include <QApplication>


using namespace std;


/// <summary>
/// 时间转换工具
/// </summary>
namespace TimeUtils {


	//格式化时间的格式
	const QString TIME_FORMAT = "HH:mm:ss";
	//格式化日期的格式
	const QString DAY_FORMAT = "yyyy-MM-dd";
	//格式化日期+时间的格式
	const QString DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss";


	//生成时间戳
	qint64 getTimeGen();

	/// <summary>
	/// 获取当前时间的字符串
	/// </summary>
	/// <returns></returns>
	QString nowDateTimeStr();


	/// <summary>
	/// 获取实时日期字符串
	/// </summary>
	/// <returns></returns>
	QString nowDateStr();


	/// <summary>
	/// 获取当前时间的字符串
	/// </summary>
	/// <param name="time"></param>
	/// <returns></returns>
	QString nowTimeStr();



	/// <summary>
	/// 格式化时间
	/// </summary>
	/// <param name="dateTime"></param>
	/// <returns></returns>
	QString formatDateTime(QDateTime& dateTime);


	/// <summary>
	/// 格式化日期
	/// </summary>
	/// <param name="day"></param>
	/// <returns></returns>
	QString formatDate(QDate& day);


	/// <summary>
	/// 格式化时间
	/// </summary>
	/// <param name="time"></param>
	/// <returns></returns>
	QString formatTime(QTime& time);


	/// <summary>
	/// 挂起线程(不阻塞线程)
	/// </summary>
	/// <param name="time"></param>
	void suspendThread(int time);

}

#endif


